home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 124 / cd-rom 124.iso / edu / tuxmath / tuxmathscrabble / tuxmathscrabble.exe / asymptopia / myutil.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2003-11-16  |  1.8 KB  |  60 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.2)
  3.  
  4. import pygame
  5. import os
  6. import sys
  7. from pygame.locals import *
  8.  
  9. try:
  10.     for sitepkgdir in sys.path:
  11.         if sitepkgdir[-13:] == 'site-packages':
  12.             break
  13.         
  14. except:
  15.     pass
  16.  
  17.  
  18. def load_image(name, colorkey = None):
  19.     fullname = os.path.join(sitepkgdir, name)
  20.     
  21.     try:
  22.         image = pygame.image.load(fullname)
  23.     except pygame.error:
  24.         message = None
  25.         print 'Cannot load image:', name
  26.         raise SystemExit, message
  27.  
  28.     image = image.convert()
  29.     if colorkey is not None:
  30.         if colorkey is -1:
  31.             colorkey = image.get_at((0, 0))
  32.         
  33.         image.set_colorkey(colorkey, RLEACCEL)
  34.     
  35.     return (image, image.get_rect())
  36.  
  37.  
  38. def load_sound(name):
  39.     
  40.     class NoneSound:
  41.         
  42.         def play(self):
  43.             pass
  44.  
  45.  
  46.     if not (pygame.mixer) or not pygame.mixer.get_init():
  47.         return NoneSound()
  48.     
  49.     fullname = os.path.join(sitepkgdir, name)
  50.     
  51.     try:
  52.         sound = pygame.mixer.Sound(fullname)
  53.     except pygame.error:
  54.         message = None
  55.         print 'Cannot load sound:', fullname
  56.         raise SystemExit, message
  57.  
  58.     return sound
  59.  
  60.